package com.xtgg.more;

import com.umeng.analytics.MobclickAgent;
import com.xtgg.R;
import com.xtgg.baby.DeviceSearchActivity;
import com.xtgg.login.SetPasswordActivity;
import com.xtgg.main.DistributeActivity;
import com.xtgg.main.MainPageActivity;
import com.xtgg.manager.BaseActivity;

import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class SearchLogActivity extends BaseActivity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search_log);

		((TextView) findViewById(R.id.center)).setText("系统设置");
		MobclickAgent.onEvent(this, ((TextView) findViewById(R.id.center))
				.getText().toString());

		findViewById(R.id.left).setOnClickListener(this);
		findViewById(R.id.action0).setOnClickListener(this);
		findViewById(R.id.action1).setOnClickListener(this);
		findViewById(R.id.action2).setOnClickListener(this);
		findViewById(R.id.action3).setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.left:
			finish();
			break;

		case R.id.action0:
			startActivity(new Intent(this, LoseListActivity.class));
			break;

		case R.id.action1:
		{
			if(MainPageActivity.mSelected == -1)
			{
				this.showToast("您还没有添加宝宝");
				return;
			}

			Intent intent = new Intent(this, DistributeActivity.class);
			intent.putExtra("baby", MainPageActivity.mArray.getJSONObject(MainPageActivity.mSelected).toJSONString());
			startActivity(intent);
		}
			break;

		case R.id.action2:
			BluetoothAdapter.getDefaultAdapter().enable();
			startActivity(new Intent(this,DeviceSearchActivity.class));
		
			break;

		case R.id.action3:
			startActivity(new Intent(this, AddNewBabyActivity.class));
			break;
		}
	}
}
